{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1efc6908a44e5c84",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-08-14T01:22:18.505098Z",
     "start_time": "2024-08-14T01:22:18.426985Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1.53398299e+00 -1.31776686e+00  1.01116088e-03  1.28640586e+00\n",
      "  -4.41521050e-01  8.82235351e-01 -4.83057920e-01 -2.95590030e-02\n",
      "   3.87828952e-01 -4.04478406e-01]\n",
      " [-8.49414502e-01 -5.99113404e-01  2.16863837e-01 -8.89760818e-01\n",
      "   2.57008992e+00 -1.81431203e-01  1.13906042e+00  1.44004475e+00\n",
      "  -9.39544372e-02  4.10011069e-01]\n",
      " [ 2.54565434e-01 -1.08381885e+00 -2.35747215e+00  5.52554229e-01\n",
      "  -1.31502680e+00 -2.26444314e-01 -1.88395720e+00  2.00845865e+00\n",
      "  -1.52780051e-01 -1.17469541e+00]]\n"
     ]
    }
   ],
   "source": [
    "# from src import data_loader\n",
    "import numpy as np\n",
    "\n",
    "x = np.arange(0, 10).reshape((1, 10))\n",
    "np.concatenate((x, [[i for i in range(0, 10)]]), axis=-2)\n",
    "y = np.random.randn(3, 10)\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "cfaa5fcdb857bdf5",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-24T09:18:38.783489Z",
     "start_time": "2024-06-24T09:18:07.896417Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "csr size: 32959746\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[12], line 12\u001b[0m\n\u001b[1;32m      9\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(G\u001b[38;5;241m.\u001b[39mget_size()):\n\u001b[1;32m     10\u001b[0m     adjlist\u001b[38;5;241m.\u001b[39mappend(csr[i]\u001b[38;5;241m.\u001b[39mnonzero()[\u001b[38;5;241m1\u001b[39m])\n\u001b[0;32m---> 12\u001b[0m \u001b[38;5;28;43mprint\u001b[39;49m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124madjlist size:\u001b[39m\u001b[38;5;124m\"\u001b[39m, lzyutil\u001b[38;5;241m.\u001b[39mget_total_size(adjlist))\n",
      "Cell \u001b[0;32mIn[12], line 12\u001b[0m\n\u001b[1;32m      9\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(G\u001b[38;5;241m.\u001b[39mget_size()):\n\u001b[1;32m     10\u001b[0m     adjlist\u001b[38;5;241m.\u001b[39mappend(csr[i]\u001b[38;5;241m.\u001b[39mnonzero()[\u001b[38;5;241m1\u001b[39m])\n\u001b[0;32m---> 12\u001b[0m \u001b[38;5;28;43mprint\u001b[39;49m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124madjlist size:\u001b[39m\u001b[38;5;124m\"\u001b[39m, lzyutil\u001b[38;5;241m.\u001b[39mget_total_size(adjlist))\n",
      "File \u001b[0;32m_pydevd_bundle/pydevd_cython_darwin_39_64.pyx:1187\u001b[0m, in \u001b[0;36m_pydevd_bundle.pydevd_cython_darwin_39_64.SafeCallWrapper.__call__\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m_pydevd_bundle/pydevd_cython_darwin_39_64.pyx:627\u001b[0m, in \u001b[0;36m_pydevd_bundle.pydevd_cython_darwin_39_64.PyDBFrame.trace_dispatch\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m_pydevd_bundle/pydevd_cython_darwin_39_64.pyx:937\u001b[0m, in \u001b[0;36m_pydevd_bundle.pydevd_cython_darwin_39_64.PyDBFrame.trace_dispatch\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m_pydevd_bundle/pydevd_cython_darwin_39_64.pyx:928\u001b[0m, in \u001b[0;36m_pydevd_bundle.pydevd_cython_darwin_39_64.PyDBFrame.trace_dispatch\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m_pydevd_bundle/pydevd_cython_darwin_39_64.pyx:585\u001b[0m, in \u001b[0;36m_pydevd_bundle.pydevd_cython_darwin_39_64.PyDBFrame.do_wait_suspend\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32m/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py:1196\u001b[0m, in \u001b[0;36mPyDB.do_wait_suspend\u001b[0;34m(self, thread, frame, event, arg, send_suspend_message, is_unhandled_exception)\u001b[0m\n\u001b[1;32m   1193\u001b[0m         from_this_thread\u001b[38;5;241m.\u001b[39mappend(frame_id)\n\u001b[1;32m   1195\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_threads_suspended_single_notification\u001b[38;5;241m.\u001b[39mnotify_thread_suspended(thread_id, stop_reason):\n\u001b[0;32m-> 1196\u001b[0m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_do_wait_suspend\u001b[49m\u001b[43m(\u001b[49m\u001b[43mthread\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mframe\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mevent\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43marg\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msuspend_type\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrom_this_thread\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py:1211\u001b[0m, in \u001b[0;36mPyDB._do_wait_suspend\u001b[0;34m(self, thread, frame, event, arg, suspend_type, from_this_thread)\u001b[0m\n\u001b[1;32m   1208\u001b[0m             \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_call_mpl_hook()\n\u001b[1;32m   1210\u001b[0m         \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocess_internal_commands()\n\u001b[0;32m-> 1211\u001b[0m         \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m0.01\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m   1213\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcancel_async_evaluation(get_current_thread_id(thread), \u001b[38;5;28mstr\u001b[39m(\u001b[38;5;28mid\u001b[39m(frame)))\n\u001b[1;32m   1215\u001b[0m \u001b[38;5;66;03m# process any stepping instructions\u001b[39;00m\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "\n",
    "from data_loader import *\n",
    "import lzyutil\n",
    "\n",
    "G = GraphDataset(\"epinions\")\n",
    "csr = G.get_adjacency_coo().tocsr()\n",
    "print(\"csr size:\", lzyutil.get_total_size(csr))\n",
    "adjlist = []\n",
    "for i in range(G.get_size()):\n",
    "    adjlist.append(csr[i].nonzero()[1])\n",
    "\n",
    "print(\"adjlist size:\", lzyutil.get_total_size(adjlist))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dd5297ea9163ada2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-24T09:40:09.592020Z",
     "start_time": "2024-06-24T09:40:08.062576Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 4, 7]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from lzyutil import *\n",
    "\n",
    "partite_batch_start_idx(10, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "64fc52b52969550c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-24T11:46:15.538112Z",
     "start_time": "2024-06-24T11:46:15.534647Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cond [0 1 1 0 0 0 0 1 1 0] int64\n",
      "idx [ 0 10 20  0  0  0  0 70 80  0] [10 20 70 80]\n",
      "[2 3 8 9]\n",
      "[ 1  0  0  4  5  6  7  0  0 10]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "infect_rate = 0.3\n",
    "rand_arr = np.random.uniform(low=0, high=1, size=10)\n",
    "cond = np.where(rand_arr < infect_rate, 1, 0)\n",
    "print(\"cond\", cond, cond.dtype)\n",
    "x = np.arange(0, 10) + 1\n",
    "idx = np.arange(0, 10) * 10 * cond\n",
    "print(\"idx\", idx, idx[idx != 0])\n",
    "print(x[idx.nonzero()[0]])\n",
    "x[idx.nonzero()[0]] = np.zeros(idx.nonzero()[0].size)\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7dc78ed1fe477cc6",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-06-25T05:58:58.846329Z",
     "start_time": "2024-06-25T05:58:58.842052Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum([5, 4, 3, 2, 1, 1, 1, 2, 1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b792ca6ae6ec45b8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-08-14T01:24:04.091458Z",
     "start_time": "2024-08-14T01:24:01.336620Z"
    }
   },
   "outputs": [],
   "source": [
    "import os\n",
    "from os.path import exists\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "from torch.nn.functional import log_softmax, pad\n",
    "import math\n",
    "import copy\n",
    "import time\n",
    "from torch.optim.lr_scheduler import LambdaLR\n",
    "import pandas as pd\n",
    "import altair as alt\n",
    "from torch.utils.data import DataLoader\n",
    "\n",
    "import spacy\n",
    "import GPUtil\n",
    "import warnings\n",
    "from torch.utils.data.distributed import DistributedSampler\n",
    "import torch.distributed as dist\n",
    "import torch.multiprocessing as mp\n",
    "from torch.nn.parallel import DistributedDataParallel as DDP\n",
    "\n",
    "# Set to False to skip notebook execution (e.g. for debugging)\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "RUN_EXAMPLES = True\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "d739a23ebe0377c1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-07-08T08:58:54.944449Z",
     "start_time": "2024-07-08T08:58:54.941671Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([10, 10]) torch.Size([10, 1, 10])\n",
      "torch.Size([5, 20])\n"
     ]
    }
   ],
   "source": [
    "mask = torch.ones(10, 10)\n",
    "print(mask.shape, mask.unsqueeze(1).shape)\n",
    "print(mask.view(5, -1).shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "77c8364ee95576f9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-07-08T10:46:33.481085Z",
     "start_time": "2024-07-08T10:46:33.475044Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[-1.0000, -1.0000, -1.0000, -1.0000],\n",
      "        [ 0.0000,  0.0000,  0.0000,  0.0000],\n",
      "        [ 1.0000,  1.0000,  1.0000,  1.0000]]) tensor([[-1.1619, -0.3873,  0.3873,  1.1619],\n",
      "        [-1.1619, -0.3873,  0.3873,  1.1619],\n",
      "        [-1.1619, -0.3873,  0.3873,  1.1619]])\n"
     ]
    }
   ],
   "source": [
    "x = torch.arange(0, 12, dtype=torch.float32).reshape((3, 4))\n",
    "bn = (x - x.mean(dim=0, keepdim=True)) / (x.std(dim=0, keepdim=True) + 1e-6)\n",
    "ln = (x - x.mean(dim=-1, keepdim=True)) / (x.std(dim=-1, keepdim=True) + 1e-6)\n",
    "print(bn, ln)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "12ab32cda2f2b7f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-07-15T08:43:59.746422Z",
     "start_time": "2024-07-15T08:43:59.734422Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "a = set()\n",
    "a.update([1, 2, 3])\n",
    "a.update([3, 4, 5])\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "2e7151f20851be62",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-07-15T08:58:46.548726Z",
     "start_time": "2024-07-15T08:58:46.345708Z"
    }
   },
   "outputs": [
    {
     "ename": "ClientConnectorError",
     "evalue": "Cannot connect to host raw.githubusercontent.com:443 ssl:default [getaddrinfo failed]",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mgaierror\u001b[0m                                  Traceback (most recent call last)",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\connector.py:1203\u001b[0m, in \u001b[0;36mTCPConnector._create_direct_connection\u001b[1;34m(self, req, traces, timeout, client_error)\u001b[0m\n\u001b[0;32m   1199\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m   1200\u001b[0m     \u001b[38;5;66;03m# Cancelling this lookup should not cancel the underlying lookup\u001b[39;00m\n\u001b[0;32m   1201\u001b[0m     \u001b[38;5;66;03m#  or else the cancel event will get broadcast to all the waiters\u001b[39;00m\n\u001b[0;32m   1202\u001b[0m     \u001b[38;5;66;03m#  across all connections.\u001b[39;00m\n\u001b[1;32m-> 1203\u001b[0m     hosts \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resolve_host(host, port, traces\u001b[38;5;241m=\u001b[39mtraces)\n\u001b[0;32m   1204\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\connector.py:880\u001b[0m, in \u001b[0;36mTCPConnector._resolve_host\u001b[1;34m(self, host, port, traces)\u001b[0m\n\u001b[0;32m    879\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 880\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m asyncio\u001b[38;5;241m.\u001b[39mshield(resolved_host_task)\n\u001b[0;32m    881\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m asyncio\u001b[38;5;241m.\u001b[39mCancelledError:\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\connector.py:917\u001b[0m, in \u001b[0;36mTCPConnector._resolve_host_with_throttle\u001b[1;34m(self, key, host, port, traces)\u001b[0m\n\u001b[0;32m    915\u001b[0m         \u001b[38;5;28;01mawait\u001b[39;00m trace\u001b[38;5;241m.\u001b[39msend_dns_resolvehost_start(host)\n\u001b[1;32m--> 917\u001b[0m addrs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resolver\u001b[38;5;241m.\u001b[39mresolve(host, port, family\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_family)\n\u001b[0;32m    918\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m traces:\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\resolver.py:33\u001b[0m, in \u001b[0;36mThreadedResolver.resolve\u001b[1;34m(self, hostname, port, family)\u001b[0m\n\u001b[0;32m     30\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mresolve\u001b[39m(\n\u001b[0;32m     31\u001b[0m     \u001b[38;5;28mself\u001b[39m, hostname: \u001b[38;5;28mstr\u001b[39m, port: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m, family: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m socket\u001b[38;5;241m.\u001b[39mAF_INET\n\u001b[0;32m     32\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[Dict[\u001b[38;5;28mstr\u001b[39m, Any]]:\n\u001b[1;32m---> 33\u001b[0m     infos \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_loop\u001b[38;5;241m.\u001b[39mgetaddrinfo(\n\u001b[0;32m     34\u001b[0m         hostname,\n\u001b[0;32m     35\u001b[0m         port,\n\u001b[0;32m     36\u001b[0m         \u001b[38;5;28mtype\u001b[39m\u001b[38;5;241m=\u001b[39msocket\u001b[38;5;241m.\u001b[39mSOCK_STREAM,\n\u001b[0;32m     37\u001b[0m         family\u001b[38;5;241m=\u001b[39mfamily,\n\u001b[0;32m     38\u001b[0m         flags\u001b[38;5;241m=\u001b[39msocket\u001b[38;5;241m.\u001b[39mAI_ADDRCONFIG,\n\u001b[0;32m     39\u001b[0m     )\n\u001b[0;32m     41\u001b[0m     hosts \u001b[38;5;241m=\u001b[39m []\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\asyncio\\base_events.py:861\u001b[0m, in \u001b[0;36mBaseEventLoop.getaddrinfo\u001b[1;34m(self, host, port, family, type, proto, flags)\u001b[0m\n\u001b[0;32m    859\u001b[0m     getaddr_func \u001b[38;5;241m=\u001b[39m socket\u001b[38;5;241m.\u001b[39mgetaddrinfo\n\u001b[1;32m--> 861\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun_in_executor(\n\u001b[0;32m    862\u001b[0m     \u001b[38;5;28;01mNone\u001b[39;00m, getaddr_func, host, port, family, \u001b[38;5;28mtype\u001b[39m, proto, flags)\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\concurrent\\futures\\thread.py:58\u001b[0m, in \u001b[0;36m_WorkItem.run\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m     57\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 58\u001b[0m     result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfn(\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwargs)\n\u001b[0;32m     59\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\socket.py:954\u001b[0m, in \u001b[0;36mgetaddrinfo\u001b[1;34m(host, port, family, type, proto, flags)\u001b[0m\n\u001b[0;32m    953\u001b[0m addrlist \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m--> 954\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m res \u001b[38;5;129;01min\u001b[39;00m \u001b[43m_socket\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgetaddrinfo\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhost\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mport\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfamily\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mtype\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mproto\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mflags\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[0;32m    955\u001b[0m     af, socktype, proto, canonname, sa \u001b[38;5;241m=\u001b[39m res\n",
      "\u001b[1;31mgaierror\u001b[0m: [Errno 11004] getaddrinfo failed",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[1;31mClientConnectorError\u001b[0m                      Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[10], line 4\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtorch_geometric\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdata\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Data\n\u001b[0;32m      2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtorch_geometric\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdatasets\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Planetoid\n\u001b[1;32m----> 4\u001b[0m dataset \u001b[38;5;241m=\u001b[39m \u001b[43mPlanetoid\u001b[49m\u001b[43m(\u001b[49m\u001b[43mroot\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m~/data/Planetoid\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mCora\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m      5\u001b[0m \u001b[38;5;28mprint\u001b[39m(dataset)\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\torch_geometric\\datasets\\planetoid.py:102\u001b[0m, in \u001b[0;36mPlanetoid.__init__\u001b[1;34m(self, root, name, split, num_train_per_class, num_val, num_test, transform, pre_transform, force_reload)\u001b[0m\n\u001b[0;32m     99\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msplit \u001b[38;5;241m=\u001b[39m split\u001b[38;5;241m.\u001b[39mlower()\n\u001b[0;32m    100\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msplit \u001b[38;5;129;01min\u001b[39;00m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpublic\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfull\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgeom-gcn\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrandom\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m--> 102\u001b[0m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__init__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mroot\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtransform\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpre_transform\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m    103\u001b[0m \u001b[43m                 \u001b[49m\u001b[43mforce_reload\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mforce_reload\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    104\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mload(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessed_paths[\u001b[38;5;241m0\u001b[39m])\n\u001b[0;32m    106\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m split \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfull\u001b[39m\u001b[38;5;124m'\u001b[39m:\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\torch_geometric\\data\\in_memory_dataset.py:81\u001b[0m, in \u001b[0;36mInMemoryDataset.__init__\u001b[1;34m(self, root, transform, pre_transform, pre_filter, log, force_reload)\u001b[0m\n\u001b[0;32m     72\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__init__\u001b[39m(\n\u001b[0;32m     73\u001b[0m     \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m     74\u001b[0m     root: Optional[\u001b[38;5;28mstr\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m     79\u001b[0m     force_reload: \u001b[38;5;28mbool\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[0;32m     80\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m---> 81\u001b[0m     \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__init__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mroot\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtransform\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpre_transform\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpre_filter\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlog\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m     82\u001b[0m \u001b[43m                     \u001b[49m\u001b[43mforce_reload\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m     84\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_data: Optional[BaseData] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m     85\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mslices: Optional[Dict[\u001b[38;5;28mstr\u001b[39m, Tensor]] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\torch_geometric\\data\\dataset.py:112\u001b[0m, in \u001b[0;36mDataset.__init__\u001b[1;34m(self, root, transform, pre_transform, pre_filter, log, force_reload)\u001b[0m\n\u001b[0;32m    109\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mforce_reload \u001b[38;5;241m=\u001b[39m force_reload\n\u001b[0;32m    111\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhas_download:\n\u001b[1;32m--> 112\u001b[0m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_download\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    114\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhas_process:\n\u001b[0;32m    115\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_process()\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\torch_geometric\\data\\dataset.py:229\u001b[0m, in \u001b[0;36mDataset._download\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    226\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[0;32m    228\u001b[0m fs\u001b[38;5;241m.\u001b[39mmakedirs(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mraw_dir, exist_ok\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m--> 229\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdownload\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\torch_geometric\\datasets\\planetoid.py:154\u001b[0m, in \u001b[0;36mPlanetoid.download\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    152\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdownload\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m    153\u001b[0m     \u001b[38;5;28;01mfor\u001b[39;00m name \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mraw_file_names:\n\u001b[1;32m--> 154\u001b[0m         \u001b[43mfs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcp\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43murl\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mname\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraw_dir\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    155\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msplit \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgeom-gcn\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m    156\u001b[0m         \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m10\u001b[39m):\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\torch_geometric\\io\\fs.py:111\u001b[0m, in \u001b[0;36mcp\u001b[1;34m(path1, path2, extract, log, use_cache, clear_cache)\u001b[0m\n\u001b[0;32m    101\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcp\u001b[39m(\n\u001b[0;32m    102\u001b[0m     path1: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m    103\u001b[0m     path2: \u001b[38;5;28mstr\u001b[39m,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m    107\u001b[0m     clear_cache: \u001b[38;5;28mbool\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[0;32m    108\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m    109\u001b[0m     kwargs: Dict[\u001b[38;5;28mstr\u001b[39m, Any] \u001b[38;5;241m=\u001b[39m {}\n\u001b[1;32m--> 111\u001b[0m     is_path1_dir \u001b[38;5;241m=\u001b[39m \u001b[43misdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpath1\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    112\u001b[0m     is_path2_dir \u001b[38;5;241m=\u001b[39m isdir(path2)\n\u001b[0;32m    114\u001b[0m     \u001b[38;5;66;03m# Cache result if the protocol is not local:\u001b[39;00m\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\torch_geometric\\io\\fs.py:59\u001b[0m, in \u001b[0;36misdir\u001b[1;34m(path)\u001b[0m\n\u001b[0;32m     58\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21misdir\u001b[39m(path: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mbool\u001b[39m:\n\u001b[1;32m---> 59\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mget_fs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpath\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43misdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpath\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\fsspec\\asyn.py:118\u001b[0m, in \u001b[0;36msync_wrapper.<locals>.wrapper\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    115\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[0;32m    116\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m    117\u001b[0m     \u001b[38;5;28mself\u001b[39m \u001b[38;5;241m=\u001b[39m obj \u001b[38;5;129;01mor\u001b[39;00m args[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m--> 118\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m sync(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mloop, func, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\fsspec\\asyn.py:103\u001b[0m, in \u001b[0;36msync\u001b[1;34m(loop, func, timeout, *args, **kwargs)\u001b[0m\n\u001b[0;32m    101\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m FSTimeoutError \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mreturn_result\u001b[39;00m\n\u001b[0;32m    102\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(return_result, \u001b[38;5;167;01mBaseException\u001b[39;00m):\n\u001b[1;32m--> 103\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m return_result\n\u001b[0;32m    104\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m    105\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m return_result\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\fsspec\\asyn.py:56\u001b[0m, in \u001b[0;36m_runner\u001b[1;34m(event, coro, result, timeout)\u001b[0m\n\u001b[0;32m     54\u001b[0m     coro \u001b[38;5;241m=\u001b[39m asyncio\u001b[38;5;241m.\u001b[39mwait_for(coro, timeout\u001b[38;5;241m=\u001b[39mtimeout)\n\u001b[0;32m     55\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 56\u001b[0m     result[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m coro\n\u001b[0;32m     57\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m ex:\n\u001b[0;32m     58\u001b[0m     result[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m ex\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\fsspec\\implementations\\http.py:516\u001b[0m, in \u001b[0;36mHTTPFileSystem._isdir\u001b[1;34m(self, path)\u001b[0m\n\u001b[0;32m    513\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_isdir\u001b[39m(\u001b[38;5;28mself\u001b[39m, path):\n\u001b[0;32m    514\u001b[0m     \u001b[38;5;66;03m# override, since all URLs are (also) files\u001b[39;00m\n\u001b[0;32m    515\u001b[0m     \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 516\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mbool\u001b[39m(\u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_ls(path))\n\u001b[0;32m    517\u001b[0m     \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mFileNotFoundError\u001b[39;00m, \u001b[38;5;167;01mValueError\u001b[39;00m):\n\u001b[0;32m    518\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\fsspec\\implementations\\http.py:207\u001b[0m, in \u001b[0;36mHTTPFileSystem._ls\u001b[1;34m(self, url, detail, **kwargs)\u001b[0m\n\u001b[0;32m    205\u001b[0m     out \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdircache[url]\n\u001b[0;32m    206\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 207\u001b[0m     out \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_ls_real(url, detail\u001b[38;5;241m=\u001b[39mdetail, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m    208\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdircache[url] \u001b[38;5;241m=\u001b[39m out\n\u001b[0;32m    209\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m out\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\fsspec\\implementations\\http.py:159\u001b[0m, in \u001b[0;36mHTTPFileSystem._ls_real\u001b[1;34m(self, url, detail, **kwargs)\u001b[0m\n\u001b[0;32m    157\u001b[0m logger\u001b[38;5;241m.\u001b[39mdebug(url)\n\u001b[0;32m    158\u001b[0m session \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mset_session()\n\u001b[1;32m--> 159\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mwith\u001b[39;00m session\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_url(url), \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mkwargs) \u001b[38;5;28;01mas\u001b[39;00m r:\n\u001b[0;32m    160\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_raise_not_found_for_status(r, url)\n\u001b[0;32m    161\u001b[0m     \u001b[38;5;28;01mtry\u001b[39;00m:\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\client.py:1197\u001b[0m, in \u001b[0;36m_BaseRequestContextManager.__aenter__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m   1196\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__aenter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m _RetType:\n\u001b[1;32m-> 1197\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_coro\n\u001b[0;32m   1198\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resp\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\client.py:581\u001b[0m, in \u001b[0;36mClientSession._request\u001b[1;34m(self, method, str_or_url, params, data, json, cookies, headers, skip_auto_headers, auth, allow_redirects, max_redirects, compress, chunked, expect100, raise_for_status, read_until_eof, proxy, proxy_auth, timeout, verify_ssl, fingerprint, ssl_context, ssl, server_hostname, proxy_headers, trace_request_ctx, read_bufsize, auto_decompress, max_line_size, max_field_size)\u001b[0m\n\u001b[0;32m    576\u001b[0m     \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mwith\u001b[39;00m ceil_timeout(\n\u001b[0;32m    577\u001b[0m         real_timeout\u001b[38;5;241m.\u001b[39mconnect,\n\u001b[0;32m    578\u001b[0m         ceil_threshold\u001b[38;5;241m=\u001b[39mreal_timeout\u001b[38;5;241m.\u001b[39mceil_threshold,\n\u001b[0;32m    579\u001b[0m     ):\n\u001b[0;32m    580\u001b[0m         \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connector \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m--> 581\u001b[0m         conn \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connector\u001b[38;5;241m.\u001b[39mconnect(\n\u001b[0;32m    582\u001b[0m             req, traces\u001b[38;5;241m=\u001b[39mtraces, timeout\u001b[38;5;241m=\u001b[39mreal_timeout\n\u001b[0;32m    583\u001b[0m         )\n\u001b[0;32m    584\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m asyncio\u001b[38;5;241m.\u001b[39mTimeoutError \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[0;32m    585\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m ServerTimeoutError(\n\u001b[0;32m    586\u001b[0m         \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConnection timeout \u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mto host \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(url)\n\u001b[0;32m    587\u001b[0m     ) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\connector.py:544\u001b[0m, in \u001b[0;36mBaseConnector.connect\u001b[1;34m(self, req, traces, timeout)\u001b[0m\n\u001b[0;32m    541\u001b[0m         \u001b[38;5;28;01mawait\u001b[39;00m trace\u001b[38;5;241m.\u001b[39msend_connection_create_start()\n\u001b[0;32m    543\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 544\u001b[0m     proto \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_connection(req, traces, timeout)\n\u001b[0;32m    545\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_closed:\n\u001b[0;32m    546\u001b[0m         proto\u001b[38;5;241m.\u001b[39mclose()\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\connector.py:944\u001b[0m, in \u001b[0;36mTCPConnector._create_connection\u001b[1;34m(self, req, traces, timeout)\u001b[0m\n\u001b[0;32m    942\u001b[0m     _, proto \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_proxy_connection(req, traces, timeout)\n\u001b[0;32m    943\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 944\u001b[0m     _, proto \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_direct_connection(req, traces, timeout)\n\u001b[0;32m    946\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m proto\n",
      "File \u001b[1;32mC:\\DevEnvConfig\\anaconda\\envs\\venv\\lib\\site-packages\\aiohttp\\connector.py:1209\u001b[0m, in \u001b[0;36mTCPConnector._create_direct_connection\u001b[1;34m(self, req, traces, timeout, client_error)\u001b[0m\n\u001b[0;32m   1206\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m\n\u001b[0;32m   1207\u001b[0m     \u001b[38;5;66;03m# in case of proxy it is not ClientProxyConnectionError\u001b[39;00m\n\u001b[0;32m   1208\u001b[0m     \u001b[38;5;66;03m# it is problem of resolving proxy ip itself\u001b[39;00m\n\u001b[1;32m-> 1209\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m ClientConnectorError(req\u001b[38;5;241m.\u001b[39mconnection_key, exc) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n\u001b[0;32m   1211\u001b[0m last_exc: Optional[\u001b[38;5;167;01mException\u001b[39;00m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m   1213\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m hinfo \u001b[38;5;129;01min\u001b[39;00m hosts:\n",
      "\u001b[1;31mClientConnectorError\u001b[0m: Cannot connect to host raw.githubusercontent.com:443 ssl:default [getaddrinfo failed]"
     ]
    }
   ],
   "source": [
    "from torch_geometric.loader import DataLoader\n",
    "from torch_geometric.data import Dataset\n",
    "from torch_geometric.datasets import Planetoid\n",
    "\n",
    "loader = DataLoader"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "90657cd1768215eb",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-08-14T07:13:19.692611Z",
     "start_time": "2024-08-14T07:13:19.318939Z"
    }
   },
   "outputs": [
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31mFailed to start the Kernel. \n",
      "\u001b[1;31mJupyter Server crashed. Unable to connect. \n",
      "\u001b[1;31mError code from Jupyter: 1\n",
      "\u001b[1;31mTraceback (most recent call last):\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/src_detection/venv/lib/python3.10/site-packages/jupyter_server/services/sessions/sessionmanager.py\", line 14, in <module>\n",
      "\u001b[1;31m    import sqlite3\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/python_local/lib/python3.10/sqlite3/__init__.py\", line 57, in <module>\n",
      "\u001b[1;31m    from sqlite3.dbapi2 import *\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/python_local/lib/python3.10/sqlite3/dbapi2.py\", line 27, in <module>\n",
      "\u001b[1;31m    from _sqlite3 import *\n",
      "\u001b[1;31mModuleNotFoundError: No module named '_sqlite3'\n",
      "\u001b[1;31m\n",
      "\u001b[1;31mDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31m\n",
      "\u001b[1;31mTraceback (most recent call last):\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/src_detection/venv/bin/jupyter-notebook\", line 5, in <module>\n",
      "\u001b[1;31m    from notebook.app import main\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/src_detection/venv/lib/python3.10/site-packages/notebook/app.py\", line 17, in <module>\n",
      "\u001b[1;31m    from jupyter_server.serverapp import flags\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/src_detection/venv/lib/python3.10/site-packages/jupyter_server/serverapp.py\", line 107, in <module>\n",
      "\u001b[1;31m    from jupyter_server.gateway.managers import (\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/src_detection/venv/lib/python3.10/site-packages/jupyter_server/gateway/managers.py\", line 32, in <module>\n",
      "\u001b[1;31m    from ..services.sessions.sessionmanager import SessionManager\n",
      "\u001b[1;31m  File \"/home/cubebase/liuzy/src_detection/venv/lib/python3.10/site-packages/jupyter_server/services/sessions/sessionmanager.py\", line 17, in <module>\n",
      "\u001b[1;31m    from pysqlite2 import dbapi2 as sqlite3  # type:ignore[no-redef]\n",
      "\u001b[1;31mModuleNotFoundError: No module named 'pysqlite2'. \n",
      "\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
     ]
    }
   ],
   "source": [
    "import torch\n",
    "import torch.nn as nn\n",
    "\n",
    "d_model = 512  # 模型的维度\n",
    "nhead = 8  # 多头注意力机制中的头数\n",
    "num_layers = 3  # 解码器层数\n",
    "vocab_size = 5  # 假设词汇表的大小\n",
    "\n",
    "# 准备输入数据\n",
    "L = 10  # 输入序列长度\n",
    "P = 15  # 输出序列长度\n",
    "batch_size = 2  # 批次大小\n",
    "desire_rst = torch.tensor([0, 0, 1, 0, 0] * (batch_size * P), dtype=torch.float32, requires_grad=False).reshape(\n",
    "    (P, batch_size, vocab_size))\n",
    "\n",
    "input_vec = torch.rand(P, batch_size, d_model, requires_grad=False)  # 需要初始化一个起始序列\n",
    "memory = torch.zeros(L, batch_size, d_model, requires_grad=False)  # Decoder-only架构中可以使用零向量作为memory\n",
    "tgt_mask = nn.Transformer.generate_square_subsequent_mask(P).detach()\n",
    "num_epochs = 10\n",
    "\n",
    "\n",
    "class MyModel(nn.Module):\n",
    "    def __init__(self):\n",
    "        super(MyModel, self).__init__()\n",
    "        # 定义DecoderLayer\n",
    "        decoder_layer = nn.TransformerDecoderLayer(d_model=d_model, nhead=nhead)\n",
    "        # 定义完整的Decoder\n",
    "        self.decoder = nn.TransformerDecoder(decoder_layer, num_layers=num_layers)\n",
    "        self.linear = nn.Linear(d_model, vocab_size)\n",
    "\n",
    "    def forward(self, x, memory, tgt_mask):\n",
    "        x = self.decoder(tgt=x, memory=memory, tgt_mask=tgt_mask)\n",
    "        return self.linear(x)\n",
    "\n",
    "\n",
    "model = MyModel()\n",
    "for p in model.parameters():\n",
    "    if p.dim() > 1:\n",
    "        nn.init.xavier_uniform_(p)\n",
    "optimizer = torch.optim.Adam(model.parameters(), lr=0.001)\n",
    "criterion = nn.MSELoss()\n",
    "loss_list = []\n",
    "for epoch in range(num_epochs):\n",
    "    output = model(input_vec, memory, tgt_mask)\n",
    "    loss = criterion(output, desire_rst)\n",
    "    loss_list.append(loss.item())\n",
    "    optimizer.zero_grad()\n",
    "    loss.backward()\n",
    "    optimizer.step()\n",
    "    print(f'Epoch [{epoch + 1}/{num_epochs}], Loss: {loss.item():.4f}')\n",
    "\n",
    "final_outputs = model(input_vec, memory, tgt_mask)\n",
    "print(\"Final Outputs:\")\n",
    "\n",
    "argmax = torch.argmax(final_outputs, dim=-1)\n",
    "print(final_outputs.shape,argmax)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "16fe50f31dcf9e67",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-08-14T07:07:52.177975Z",
     "start_time": "2024-08-14T07:07:52.156118Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[[1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5]],\n",
      "\n",
      "        [[1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5]],\n",
      "\n",
      "        [[1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5]],\n",
      "\n",
      "        [[1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5]],\n",
      "\n",
      "        [[1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5],\n",
      "         [1, 2, 3, 4, 5]]])\n"
     ]
    }
   ],
   "source": [
    "print(torch.tensor([1, 2, 3, 4, 5] * 50).reshape((5, 10, 5)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3d9939a2669f4d07",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
